using UnityEngine;
using Utility.GameEvents.Core;

namespace Utility.GameEvents.Examples {
    public class Enemy : MonoBehaviour {
        public string enemyType = "Goblin";
        public int pointsValue = 50;
        public int hp = 5;
        public void Defeated() {
            EventBus.Raise<EnemyDefeatedEvent>(new EnemyDefeatedEvent(enemyType, pointsValue));
        }

        [ContextMenu("Test Defeat Enemy")]
        void TestDefeat() {
            Defeated();
        }

        public void TakeDamage(int amount) {
            hp -= amount;
            if (hp <= 0) {
                Defeated();
                hp = 5;
            }
        }
    }
}